package com.stars.empoly.activity

import android.Manifest
import com.eazypermissions.common.model.PermissionResult
import com.eazypermissions.coroutinespermission.PermissionManager
import com.qmuiteam.qmui.kotlin.onClick
import com.stars.empoly.base.MBActivity
import com.stars.empoly.databinding.ActivityAboutUsBinding
import com.stars.empoly.vmodel.AboutUsVModel
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch
import kotlinx.coroutines.launch

/**
 *on 2021/5/15
 */
class AboutUsActivity: MBActivity<AboutUsVModel, ActivityAboutUsBinding>() {


    override fun listeners() {
        super.listeners()
        binding.llCall.onClick {

            launch {
                val requestPermissions = PermissionManager.requestPermissions(
                        this@AboutUsActivity, 1000, Manifest.permission.CALL_PHONE
                )
                if (requestPermissions is PermissionResult.PermissionGranted) {
                    //拨打电话
                    vm.toCall()
                }
            }

        }
        binding.llOne.onClick {
            UiSwitch.bundle(context(),
                    ArticleDetailActivity::class.java, B().putString("type","1").ok())
        }
        binding.llTwo.onClick {
            UiSwitch.bundle(context(),
                    ArticleDetailActivity::class.java, B().putString("type","2").ok())
        }


    }

    override fun vmClass(): Class<AboutUsVModel> {
        return AboutUsVModel::class.java
    }
    override fun binding(): ActivityAboutUsBinding {
       return ActivityAboutUsBinding.inflate(layoutInflater)
    }

    override fun title(): String? {
        return "关于我们"
    }
}
